package com.kai.mqtt.exception;

import com.kai.mqtt.enums.ErrorCodeEnum;
import lombok.Getter;

import java.io.Serial;

/**
 * @author weijk
 * @since 2024/7/2
 */
@Getter
public class BusinessException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = -2496901041997056896L;

    private final int errorCode;

    public BusinessException(ErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getMsg());
        this.errorCode = errorCodeEnum.getCode();
    }

    public BusinessException(String msg) {
        super(msg);
        this.errorCode = ErrorCodeEnum.BASE_ERROR.getCode();
    }
}
